#include <stdio.h>
#include "XDraow.h"


void draw_polyline(Shape *shape);
void draw_rectangle(Shape *shape);
void draw_ellipse(Shape *shape);

void (*draw_shape_func_table[])(Shape *shape) = {//draw_shape_func_table 的类型为“指向（以指向 Shape的指针为参数的）函数的指针的数组”
      draw_polyline,
      draw_rectangle,
      draw_ellipse
};


void draw_shape(Shape *shape){
     draw_shape_func_table[shape->u.primitive.type](shape);
}

//以下方式和上面等价，更便于理解
typedef (*DrawFun) (Shape *shape);
DrawFun draw_shape_func_table2[] = {
      draw_polyline,
      draw_rectangle,
      draw_ellipse
};


int main(void ){
     return 0;
}